﻿
@{
	ViewData["Title"] = "Login";
	Layout = null;
}

@{
	ViewData["Title"] = "Index";
	Layout = null;
}
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<title>登录</title>
	<link href="~/weui.css" rel="stylesheet" />
	 
	<script src="~/weui.js"></script>
	<script src="~/jquery.min.js"></script> 
</head>
<body ontouchstart>
	<p id="bear"></p>
	<div id="form"> 
		<div class="weui-cells weui-cells_form">
			<div class="weui-cell">
				<div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
				<div class="weui-cell__bd">
					<input id="txtUserName" class="weui-input" type="text" required pattern="^\d{11}$" maxlength="11" placeholder="输入用户名" emptyTips="请输入用户名" notMatchTips="请输入用户名">
				</div>
				<div class="weui-cell__ft">
					<i class="weui-icon-warn"></i>
				</div>
			</div>

			<div class="weui-cell">
				<div class="weui-cell__hd"><label class="weui-label">密码</label></div>
				<div class="weui-cell__bd">
					<input id="txtPwd" class="weui-input" type="password" required pattern="^\d{11}$" maxlength="11" placeholder="输入密码" emptyTips="请输入密码" notMatchTips="请输入密码">
				</div>
				<div class="weui-cell__ft">
					<i class="weui-icon-warn"></i>
				</div>
			</div>

		</div>
		<div class="weui-btn-area">
			<a id="formSubmitBtn" href="javascript:" class="weui-btn weui-btn_primary">提交</a>
		</div>
	</div>
</body>
</html>
<script>
	 
	$(function () {
		$('#formSubmitBtn').click(function () {
			var userName =$.trim( $('#txtUserName').val()+"");
			var pwd = $.trim($('#txtPwd').val() + "");
			if (userName.length == 0) {
				weui.topTips('请填写用户名');
				return;
			}

			if (pwd.length == 0) {
				weui.topTips('请填写密码');
				return;
			}
		 
			$.post("Login", { "UserName": userName, "Password": pwd, "RememberMe": true }, function (res) {
				if(res.code==0)
					window.location.href = "/";
				else {
					weui.topTips('登录失败,请重试!');
					return;
				}
			});
			

		});
	})
</script>